﻿using System;
using System.Xml;

using DeepEarth.BingMapsToolkit.Client.Common.Entities;
using System.Text;

using GeoAPI.Geometries;

namespace SMIL.DrawingTools
{
    public class StyledGeometry
    {
        public StyleSpecification GeometryStyle { get; set; }

        public IGeometry Geometry { get; set; }

        public StyledGeometry(StyleSpecification styleSpecification = null, IGeometry geometry = null)
        {
            if (null != styleSpecification)
                GeometryStyle = styleSpecification;

            if (null != geometry)
                Geometry = geometry;
        }

        public static void GetStyledGeomsAsXML(System.Collections.Generic.ICollection<StyledGeometry> geoms, XmlWriter xmlWriter)
        {
            xmlWriter.WriteStartDocument();
            xmlWriter.WriteStartElement("StyledGeometrys");
            foreach (var item in geoms)
            {
                xmlWriter.WriteStartElement("StyledGeometry");
                xmlWriter.WriteRaw(item.GeometryStyle.ToXML());
                xmlWriter.WriteStartElement("Geometry");
                xmlWriter.WriteString(item.Geometry.AsText());
                xmlWriter.WriteEndElement(); // end geometry
                xmlWriter.WriteEndElement(); // end StyledGeometry
            }
            xmlWriter.WriteEndElement();
            xmlWriter.WriteEndDocument();
        }
    }
}
